import request from "@/api";

/**
 * @description 获取文章列表
 * @param page 当前页码
 * @param pageSize 每页条数
 * @param sort 排序规则
 * @param filter 筛选条件
 */
export const getArticleListAPI = async (page = 6, pageSize = 1, sort = { _id: 1 }, filter = {}) => {
    return request({
        url: '/article/getArticleList',
        method: 'post',
        data: {
            page,
            pageSize,
            sort,
            filter
        }
    });
};

/**
 * @deascription 获取当前文章详情
 * @param id
 */

export async function getArticleDetailAPI(id: string) {
    return request({
        url: '/article/getArticleDetail',
        method: 'post',
        data: {
            id
        }
    })
}

/**
 * @description 获取全部文档列表
 */

export async function getAllArticleListAPI() {
    return request.get("/article/getAllArticleList")
}

/**
 * @description 根据分类和标签获取文章列表
 */
export async function getArticleListByCategoryAndTagAPI(category: string, tag: string | null) {
    console.log(category, tag);
    return request({
        url: '/article/getArticleByCategoryAndTag',
        method: 'post',
        data: {
            category,
            tag
        }
    })
}